package weekMatch.two_102;

import java.util.Arrays;

public class LeeCode_02 {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(findPrefixScore(new int[]{2, 3, 7, 5, 10})));
    }
    private static long[] findPrefixScore(int[] nums) {
        int n = nums.length;
        int[] maxes = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (nums[i] > max){
                max = nums[i];
                maxes[i] = nums[i];
            }else {
                maxes[i] = max;
            }
        }
        int[] convers = new int[n];
        for (int i = 0; i < n; i++) {
            convers[i] = nums[i] + maxes[i];
        }
        long[] ans = new long[n];
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                ans[i] = convers[i];
                continue;
            }
            ans[i] = ans[i - 1] + convers[i];
        }
        return ans;
    }
}
